package lambda;

import java.io.File;
import java.io.FileFilter;

/**
 * lambda表达式  JDK8之后推出的新特性
 * 语法:
 * (参数列表)->{
 *     方法体
 * }
 */
public class LambdaDemo {
    public static void main(String[] args) {
        FileFilter filter1 = new FileFilter() {
            public boolean accept(File f) {
                return f.length()>50;
            }
        };
        FileFilter filter2 = (File f)->{
                return f.length()>50;
        };
        FileFilter filter3 = (f)->{
            return f.length()>50;
        };
        FileFilter filter4 = f->{
            return f.length()>500;
        };
        FileFilter filter5 = f->f.length()>500;
        File dir = new File("./src/file");
        if(dir.isDirectory()){
            //匿名内部类形式
//            File[] subs = dir.listFiles(new FileFilter() {
//                public boolean accept(File file) {
//                    return file.length()>1000;
//                }
//            });
            File[] subs = dir.listFiles(f->f.length()>1000);
            for(int i=0;i<subs.length;i++){
                System.out.println(subs[i].getName()+":"+subs[i].length());
            }
        }


    }
}







